/*
//
//              INTEL CORPORATION PROPRIETARY INFORMATION
//  This software is supplied under the terms of a license  agreement or
//  nondisclosure agreement with Intel Corporation and may not be copied
//  or disclosed except in  accordance  with the terms of that agreement.
//    Copyright (c) 2007-2008 Intel Corporation. All Rights Reserved.
//
//
*/

#ifndef __UMC_AVS_ENC_FUSION_CORE_H
#define __UMC_AVS_ENC_FUSION_CORE_H

#include "umc_avs_enc.h"
#include "umc_avs_dec_fusion_core.h"

namespace UMC
{

// forward declaration of used types
class VideoData;
class MeFrame;

class AVSEncFusionCore : public AVSFusionCore
{
public:
    // Default constructor
    AVSEncFusionCore(void);
    // Destructor
    virtual
    ~AVSEncFusionCore(void);

    // Initialize the core
    virtual
    Status Init(Ipp32u numThreads, BaseCodecParams *pParams);
    // Add a piece of source data to the core
    virtual
    Status LoadSource(MediaData *pSrc);
    // Set destination fideo frame
    virtual
    Status SetDestination(MediaData *pDst);

protected:
    // pointer on the copy of encoder's params
    const AVSVideoEncoderParams* m_pAVSCompressorParams;
    
    // Release the object
    Status Release(void);

    // Allocate one more frame
    virtual
    AVSListElement<AVSFrame> *AllocateFrame(void);
    // Allocate one more slice
    virtual
    AVSListElement<AVSSlice> *AllocateSlice(void);

    // Allocates slices & memory pieces for picture
    Status AllocateSlices(AVSFrame *pFrame, VideoData * /* pVideoSrc*/);

    // check used MeFrames and mark unused
    Status CheckMeFramesList(void);
    
    // max number of res franes is 8, and alloc only 8 now!
    MeFrame* m_pMeFramesList[8];
    Ipp32s m_meMask;
    Ipp32s m_meMaskBFrame;
    Ipp8u *m_pMeMemoryChunk;
    Ipp32s m_qp;

};

Ipp32u IsThereSomethingToEncode(AVSListElement<AVSFrame> *pFrameList);

} // namespace UMC

#endif // __UMC_AVS_ENC_FUSION_CORE_H
